package com.myboot.demo.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.myboot.demo.enums.ProductStatusEnum;
import com.myboot.demo.utils.EnumUtil;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: 韦溜溜
 * @Description:商品明细表
 * @Date: Create in 9:22 2018/11/25
 */
@Entity
@Data
@DynamicUpdate
public class ProductInfo implements Serializable {

    private static final long serialVersionUID = -5922022409329574802L;
    @Id
    private String productId;
    /**
     * 商品名字
     */
    private String productName;

    /**
     *商品价格
     */
    private BigDecimal productPrice;

    /**
     * 商品库存
     */
    private Integer productStock;

    /**
     * 商品描述
     */
    private String productDescription;

    /**
     * 商品小图
     */
    private String productIcon;

    /**
     * 商品状态,0正常1下架
     */
    private Integer productStatus = ProductStatusEnum.UP.getCode();

    /**
     *类目编号
     */
    private Integer categoryType;

    private Date createTime;

    private Date updateTime;

    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum (){
        return EnumUtil.getBycode(productStatus,ProductStatusEnum.class);
    }


}
